﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Epitech.Krisk.Xna.UI.Game.Menu.Intro
{
    class Strategie : ISequenceIntro
    {
        Vector2 strategiepos;
        Vector2 imgpos;
        List<Texture2D> _strategie;
        Texture2D _strategieText;
        bool done1;
        bool done2;
        bool done3;

        int ct;

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            if (ct < 4)
                spriteBatch.Draw(_strategie[ct], imgpos, Color.White);
            spriteBatch.Draw(_strategieText, strategiepos, Color.White);
            spriteBatch.End();
        }

        public void LoadContent(ContentManager _content)
        {
            ct = 0;
            done1 = false;
            done2 = false;
            done3 = false;
            strategiepos = new Vector2(100, 100);
            imgpos = new Vector2(0, 0);
            _strategie = new List<Texture2D>();
            Texture2D tmp;

            for (int i = 1; i <= 4; i++)
            {
                tmp = _content.Load<Texture2D>("Intro/Strategie/0" + i);
                _strategie.Add(tmp);
            }
            _strategieText = _content.Load<Texture2D>("Intro/Strategie/Strategie");
        }

        public void UnloadContent()
        {
        }

        public void Update(GameTime gameTime, TimeSpan _time)
        {
            if (_time.TotalSeconds >= 4.5 && done3 == false)
            {
                ct += 1; // 3
                done3 = true;
            }
            else if (_time.TotalSeconds >= 4.0 && done2 == false)
            {
                ct += 1; // 2
                done2 = true;
            }
            else if (_time.TotalSeconds >= 3.5 && done1 == false)
            {
                ct += 1; // 1
                done1 = true;
            }
            strategiepos.X += 0.1f * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
        }
    }
}
